package com.reins.bookstore.daoimpl;

import com.reins.bookstore.dao.BasketDao;
import com.reins.bookstore.dao.BookDao;
import com.reins.bookstore.entity.Basketline;
import com.reins.bookstore.entity.Book;
import com.reins.bookstore.repository.BasketlineRepository;
import com.reins.bookstore.repository.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class BookDaoImpl implements BookDao {

    @Autowired
    BookRepository bookRepository;

    @Override
    public Book findById(Integer id){
        return bookRepository.findById(id).get();
    }
    @Override
    public List<Book> findAll(){
        return bookRepository.findAll();
    }

    @Override
    public Book save(Book add){return bookRepository.saveAndFlush(add);}
    @Override
    public void deleteById(Integer id){bookRepository.deleteById(id);}

}
